package de.rts.xml;

import de.rts.components.RailwayMap;

public class MapLoader
{
  private static final String XML     = "RailwayMap.xml";
  private static String       xmlPath = XML;
  private RailwayMap          railwayMap;
  private MapParser           parser;

  public MapLoader()
  {
    this(xmlPath);
  }

  public MapLoader(String xmlURI)
  {
    xmlPath = xmlURI;
    parser = new MapParser();
  }

  public RailwayMap loadMap()
  {
    try
    {
      railwayMap = (RailwayMap) parser.parseFile(xmlPath);
      return railwayMap;
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }
}
